package com.bean;

import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.substation.utils.SPUtils;

import java.util.List;

/**
 * Created by admin on 2018/5/21.
 */

public class LoginInfo {

    public static void save(Context context, LoginInfo info) {
        String loginInfo = JSON.toJSONString(info);
        SPUtils.put(context, "LoginInfo", loginInfo);
    }

    public static void remove(Context context){
        SPUtils.remove(context,"LoginInfo");
        loginInfo=null;
    }

    private static LoginInfo loginInfo;

    public static LoginInfo getInfo(Context context) {
        if (loginInfo == null) {
            String info = (String) SPUtils.get(context, "LoginInfo", "");
            loginInfo = JSON.parseObject(info, LoginInfo.class);
        }
        return loginInfo;
    }


    /**
     * token : TOKEN 1940/a856e278-aa1a-4809-8547-86f52a6ea769
     * authorities : ["provider-checker"]
     * rongcloud : rongcloud/a856e278-aa1a-4809-8547-86f52a6ea769
     * accountProfileDetails : {"objectId":1940,"nickname":"用检员T","sex":"M","sign":"ssss","head":{"objectId":70,"internal":true,"url":"http://192.168.1.253:81/profile/1940/4f0bdffd-4de1-4790-bba6-4147fbc00b85.jpg"},"restBirthday":1491840000000,"restEmail":"111@qq.com","restAccountVipBean":{"objectId":1940,"restName":"用检员T","restSign":"ssss","restCommentQuestionNo":0,"restFollowNo":30,"restDeFollowNo":28,"restHead":{"objectId":70,"internal":true,"url":"1940/4f0bdffd-4de1-4790-bba6-4147fbc00b85.jpg"},"restTags":[],"restBirthday":1491840000000,"restIsfollow":false}}
     * providerUserInfo : {"phoneNumber":"18702872937","providerId":90,"provideName":"电眼县供电公司","id":1940,"alongDeparrment":"","classGroup":"1056001","post":"1057001","certificateNumber":"","creatorId":0,"createdTime":0}
     * customerId : 0
     */

    private String token;
    private String rongcloud;
    private AccountProfileDetailsBean accountProfileDetails;
    private ProviderUserInfoBean providerUserInfo;
    private Long customerId;
    private List<String> authorities;

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getRongcloud() {
        return rongcloud;
    }

    public void setRongcloud(String rongcloud) {
        this.rongcloud = rongcloud;
    }

    public AccountProfileDetailsBean getAccountProfileDetails() {
        return accountProfileDetails;
    }

    public void setAccountProfileDetails(AccountProfileDetailsBean accountProfileDetails) {
        this.accountProfileDetails = accountProfileDetails;
    }

    public ProviderUserInfoBean getProviderUserInfo() {
        return providerUserInfo;
    }

    public void setProviderUserInfo(ProviderUserInfoBean providerUserInfo) {
        this.providerUserInfo = providerUserInfo;
    }

    public Long getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }

    public List<String> getAuthorities() {
        return authorities;
    }

    public void setAuthorities(List<String> authorities) {
        this.authorities = authorities;
    }

    public static class AccountProfileDetailsBean {
        /**
         * objectId : 1940
         * nickname : 用检员T
         * sex : M
         * sign : ssss
         * head : {"objectId":70,"internal":true,"url":"http://192.168.1.253:81/profile/1940/4f0bdffd-4de1-4790-bba6-4147fbc00b85.jpg"}
         * restBirthday : 1491840000000
         * restEmail : 111@qq.com
         * restAccountVipBean : {"objectId":1940,"restName":"用检员T","restSign":"ssss","restCommentQuestionNo":0,"restFollowNo":30,"restDeFollowNo":28,"restHead":{"objectId":70,"internal":true,"url":"1940/4f0bdffd-4de1-4790-bba6-4147fbc00b85.jpg"},"restTags":[],"restBirthday":1491840000000,"restIsfollow":false}
         */

        private Long objectId;
        private String nickname;
        private String sex;
        private String sign;
        private HeadBean head;
        private Long restBirthday;
        private String restEmail;
        private RestAccountVipBeanBean restAccountVipBean;

        public Long getObjectId() {
            return objectId;
        }

        public void setObjectId(Long objectId) {
            this.objectId = objectId;
        }

        public String getNickname() {
            return nickname;
        }

        public void setNickname(String nickname) {
            this.nickname = nickname;
        }

        public String getSex() {
            return sex;
        }

        public void setSex(String sex) {
            this.sex = sex;
        }

        public String getSign() {
            return sign;
        }

        public void setSign(String sign) {
            this.sign = sign;
        }

        public HeadBean getHead() {
            return head;
        }

        public void setHead(HeadBean head) {
            this.head = head;
        }

        public Long getRestBirthday() {
            return restBirthday;
        }

        public void setRestBirthday(Long restBirthday) {
            this.restBirthday = restBirthday;
        }

        public String getRestEmail() {
            return restEmail;
        }

        public void setRestEmail(String restEmail) {
            this.restEmail = restEmail;
        }

        public RestAccountVipBeanBean getRestAccountVipBean() {
            return restAccountVipBean;
        }

        public void setRestAccountVipBean(RestAccountVipBeanBean restAccountVipBean) {
            this.restAccountVipBean = restAccountVipBean;
        }

        public static class HeadBean {
            /**
             * objectId : 70
             * internal : true
             * url : http://192.168.1.253:81/profile/1940/4f0bdffd-4de1-4790-bba6-4147fbc00b85.jpg
             */

            private Long objectId;
            private boolean internal;
            private String url;

            public Long getObjectId() {
                return objectId;
            }

            public void setObjectId(Long objectId) {
                this.objectId = objectId;
            }

            public boolean isInternal() {
                return internal;
            }

            public void setInternal(boolean internal) {
                this.internal = internal;
            }

            public String getUrl() {
                return url;
            }

            public void setUrl(String url) {
                this.url = url;
            }
        }

        public static class RestAccountVipBeanBean {
            /**
             * objectId : 1940
             * restName : 用检员T
             * restSign : ssss
             * restCommentQuestionNo : 0
             * restFollowNo : 30
             * restDeFollowNo : 28
             * restHead : {"objectId":70,"internal":true,"url":"1940/4f0bdffd-4de1-4790-bba6-4147fbc00b85.jpg"}
             * restTags : []
             * restBirthday : 1491840000000
             * restIsfollow : false
             */

            private Long objectId;
            private String restName;
            private String restSign;
            private int restCommentQuestionNo;
            private int restFollowNo;
            private int restDeFollowNo;
            private RestHeadBean restHead;
            private long restBirthday;
            private boolean restIsfollow;
            private List<?> restTags;

            public Long getObjectId() {
                return objectId;
            }

            public void setObjectId(Long objectId) {
                this.objectId = objectId;
            }

            public String getRestName() {
                return restName;
            }

            public void setRestName(String restName) {
                this.restName = restName;
            }

            public String getRestSign() {
                return restSign;
            }

            public void setRestSign(String restSign) {
                this.restSign = restSign;
            }

            public int getRestCommentQuestionNo() {
                return restCommentQuestionNo;
            }

            public void setRestCommentQuestionNo(int restCommentQuestionNo) {
                this.restCommentQuestionNo = restCommentQuestionNo;
            }

            public int getRestFollowNo() {
                return restFollowNo;
            }

            public void setRestFollowNo(int restFollowNo) {
                this.restFollowNo = restFollowNo;
            }

            public int getRestDeFollowNo() {
                return restDeFollowNo;
            }

            public void setRestDeFollowNo(int restDeFollowNo) {
                this.restDeFollowNo = restDeFollowNo;
            }

            public RestHeadBean getRestHead() {
                return restHead;
            }

            public void setRestHead(RestHeadBean restHead) {
                this.restHead = restHead;
            }

            public long getRestBirthday() {
                return restBirthday;
            }

            public void setRestBirthday(long restBirthday) {
                this.restBirthday = restBirthday;
            }

            public boolean isRestIsfollow() {
                return restIsfollow;
            }

            public void setRestIsfollow(boolean restIsfollow) {
                this.restIsfollow = restIsfollow;
            }

            public List<?> getRestTags() {
                return restTags;
            }

            public void setRestTags(List<?> restTags) {
                this.restTags = restTags;
            }

            public static class RestHeadBean {
                /**
                 * objectId : 70
                 * internal : true
                 * url : 1940/4f0bdffd-4de1-4790-bba6-4147fbc00b85.jpg
                 */

                private Long objectId;
                private boolean internal;
                private String url;

                public Long getObjectId() {
                    return objectId;
                }

                public void setObjectId(Long objectId) {
                    this.objectId = objectId;
                }

                public boolean isInternal() {
                    return internal;
                }

                public void setInternal(boolean internal) {
                    this.internal = internal;
                }

                public String getUrl() {
                    return url;
                }

                public void setUrl(String url) {
                    this.url = url;
                }
            }
        }
    }

    public static class ProviderUserInfoBean {
        /**
         * phoneNumber : 18702872937
         * providerId : 90
         * provideName : 电眼县供电公司
         * id : 1940
         * alongDeparrment :
         * classGroup : 1056001
         * post : 1057001
         * certificateNumber :
         * creatorId : 0
         * createdTime : 0
         */

        private String phoneNumber;
        private Long providerId;
        private String provideName;
        private Long id;
        private String alongDeparrment;
        private String classGroup;
        private String post;
        private String certificateNumber;
        private Long creatorId;
        private Long createdTime;

        public String getPhoneNumber() {
            return phoneNumber;
        }

        public void setPhoneNumber(String phoneNumber) {
            this.phoneNumber = phoneNumber;
        }

        public Long getProviderId() {
            return providerId;
        }

        public void setProviderId(Long providerId) {
            this.providerId = providerId;
        }

        public String getProvideName() {
            return provideName;
        }

        public void setProvideName(String provideName) {
            this.provideName = provideName;
        }

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
            this.id = id;
        }

        public String getAlongDeparrment() {
            return alongDeparrment;
        }

        public void setAlongDeparrment(String alongDeparrment) {
            this.alongDeparrment = alongDeparrment;
        }

        public String getClassGroup() {
            return classGroup;
        }

        public void setClassGroup(String classGroup) {
            this.classGroup = classGroup;
        }

        public String getPost() {
            return post;
        }

        public void setPost(String post) {
            this.post = post;
        }

        public String getCertificateNumber() {
            return certificateNumber;
        }

        public void setCertificateNumber(String certificateNumber) {
            this.certificateNumber = certificateNumber;
        }

        public Long getCreatorId() {
            return creatorId;
        }

        public void setCreatorId(Long creatorId) {
            this.creatorId = creatorId;
        }

        public Long getCreatedTime() {
            return createdTime;
        }

        public void setCreatedTime(Long createdTime) {
            this.createdTime = createdTime;
        }
    }
}
